package com.atxiaodei.nio.nioday01;

import org.junit.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;

/**
 * @author wangmeng
 * @date 2020/9/19
 **/
public class StreamApi13流逐行文件处理 {

    /**
     * Java 8逐行读取文件 并输出
     */
    @Test
    public void test1(){

        Path path = Paths.get("C:/Users/issuser/Desktop/5.13测试问题.txt");
        try {
            Stream<String> lines = Files.lines(path)
                                    .filter(s->s.contains("问题"));

            lines.forEach(System.out::println);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {

        }

    }
}
